package com.hitech.service;

import java.io.IOException;

import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

import com.rabbitmq.client.Channel;

@Service
public class MessageListener {

	@RabbitListener(bindings= {@QueueBinding(
			value=@Queue(value="queue_name", durable="true",autoDelete="false"),
			exchange=@Exchange(value="exchange_name",type="topic",durable="true"),
			key="key_name")})
	public void messageConsumer(Message message, Channel channel) throws IOException {
		System.out.println(message);
		channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);
	}
}
